#include <ncurses.h>
#include <stdlib.h>

#include "parser.h"

cmd_parser:: cmd_parser () {
	cmd_buf = (char*) malloc (BUF_LEN*sizeof(char));
	for (unsigned i = 0; i < BUF_LEN; i++) // zero out the buffer just in case
		cmd_buf[i] = 0;

	len = BUF_LEN;
	wr_index = 0;
}

cmd_parser:: ~cmd_parser () {
	free (cmd_buf);
}

void cmd_parser:: buf_realloc () { // increases buffer size
	len += BUF_LEN;
	cmd_buf = (char*) realloc (cmd_buf, len*sizeof(char));
}

void cmd_parser:: cmd_getch () {
	char c = getch ();
	if (c != '\n')
		cmd_buf[wr_index] = c;
}

void cmd_dispatch () {
}
